home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8294 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: bmtlh10.bnr.ca!news
  2. From: John Hickin <hickin@bnr.ca>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Convert string to char*
  5. Date: 16 Feb 1996 16:55:08 GMT
  6. Organization: Bell-Northern Research
  7. Message-ID: <4g2ctc$o6@bmtlh10.bnr.ca>
  8. References: <4g1ojq$r4r@lal.interserv.net>
  9. NNTP-Posting-Host: bmtlh520.bnr.ca
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.1 (X11; I; HP-UX A.09.05 9000/715)
  14. X-URL: news:4g1ojq$r4r@lal.interserv.net
  15.  
  16. dvisage@interserv.com wrote:
  17.     P.S - This is the reason that the ANSI string class requires you to call
  18.              the member function data() to get the chararacter string pointer
  19.              of a string data type.  It used to be called c_str().
  20.  
  21. c_str() is still available, at least in the Jan 1996 DWP
  22.     http://www.cygnus.com/misc/wp/jan96/
  23.  
  24. The difference between data() and c_str() is that data() returns a pointer to
  25. the first charT of the string which may not have a traits::eos() at the end
  26. while c_str() guarantees that this termination charT is there.  The wording of
  27. the DWP for data() is very carefully done so as to avoid unduely constraining
  28. the implementation.  I would suggest to use c_str() unless you really know what
  29. you are doing.
  30.  
  31. -- 
  32. John Hickin      Nortel Technology, Montreal, Quebec
  33. (514) 765-7924   hickin@bnr.ca
  34.  
  35.